package com.example.demo.model;

import com.example.demo.enums.ResponseCodeStatus;
import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String errMsg;
    private T data;
    public static  <T> Result success(T data){
        Result result = new Result();
        result.setCode(ResponseCodeStatus.SUCCESS.getCode());
        result.setData(data);
        return result;
    }

    public static <T> Result fail(String errMsg){
        Result result = new Result();
        result.setCode(ResponseCodeStatus.FAIL.getCode());
        result.setErrMsg(errMsg);
        return result;
    }
    public static <T> Result nologin(T data){
        Result result = new Result();
        result.setCode(ResponseCodeStatus.NO_LOGIN.getCode());
        result.setErrMsg("未登录!");
        return result;
    }

}
